<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Zeta-Daryll
 * Date: 6/17/14
 * Time: 12:09 PM
 * To change this templates use File | Settings | File Templates.
 */
class Emailmodel extends CI_Model {
    
    function new_register($to,$name,$password,$Regdate,$key) {
        $body = '
            <html>
            <head><title>Registration Account</title></head>
            <body style="margin:0px; padding:0px; font-family:Tahoma; font-size:12px; color:#000;">
            <div class="container" style="width:40%; margin:auto;">
                <div class="header-mail" style="height:50px; line-height:50px; background-color:#FF9A24; padding:0px 20px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -moz-border-radius-topleft: 5px; -moz-border-radius-topright: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px;">
                    <h3>New Registration Account</h3>
                </div>
                <div class="content-mail" style="background-color:#EAEAEA; padding:30px; color:#000000">
                    <h4 ><a style="color:#FF305F" href="'.base_url().'/admin/verify_email/'.$key.'">Please don\'t forget to verify your mail Click here to verify your mail.</a></h4>
                    <br/><br/>
                    <strong>Your Information Account:</strong>
                    <br/>
                    <table style="font-family:Tahoma; font-size:12px; color:#000;">

                        <tr>
                            <td style="width:120px;">Full name:</td>
                            <td>'.$name.'</td>
                        </tr>
                        <tr>
                            <td style="width:120px;">user\'s email:</td>
                            <td>'.$to.'</td>
                        </tr>
                        <tr>
                            <td>Password:</td>
                            <td>'.$password.'</td>
                        </tr>
                        <tr>
                            <td>Date Join:</td>
                            <td>'.$Regdate.'</td>
                        </tr>
                    </table>
                </div>
                <div class="footer-mail" style="height:50px; line-height:50px; background-color:#FF9A24; padding:0px 20px; text-align:center; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomright: 5px; -moz-border-radius-bottomleft: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px;">
                    Crowdpp Project &copy; 2014
                </div>
            </div>
            </body>
            </html>
        ';
        $this->mailler($to,'New Registration',$body);
    }    
    function mailler($to,$subject,$message) {
        $config = Array(
            'protocol' => 'smtp',
            'smtp_host' => 'ssl://smtp.googlemail.com',
            'smtp_port' => 465,
            'smtp_user' => 'crowdpp.project@gmail.com',
            'smtp_pass' => '4f1563ck',
            'mailtype'  => 'html',
            'charset'   => 'iso-8859-1'
        );
        $this->load->library('email', $config);
        $this->email->set_newline("\r\n");
        $this->email->from('no-reply@crowdpp.com', $this->config->item('website_name', 'system'));
        $this->email->to($to);
        $this->email->subject($subject);
        $this->email->message($message);
        $this->email->send();
        // echo $this->email->print_debugger();
    }
}
